/**
 * @(#)ChannelApkInfoImpl.java 2016年9月22日
 * Copyright(C) 2015 ZHEXIN IT CO.,LTD. All rights reserved.
 */
package org.jsbd.boss.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.jsbd.boss.common.redis.RedisClient;
import org.jsbd.boss.dao.IChannelRetentConfigDAO;
import org.jsbd.boss.domian.channel.ChannelRetentConfig;
import org.jsbd.boss.util.CacheKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import edu.hziee.common.dbroute.BaseDAO;

/**
 * TODO 请加入本类的说明
 * 
 * @author <a href="mailto:zhangbinghua@zhexinit.com" >zbh</a>
 * @version 1.0.0
 */
public class ChannelRetentConfigDAOImpl extends BaseDAO implements IChannelRetentConfigDAO {
	public static final Logger LOGGER = LoggerFactory.getLogger(ChannelRetentConfigDAOImpl.class);

	@Resource
	private RedisClient redisClient;

	@Override
	public void insertConfig(List<ChannelRetentConfig> list) {
		super.batchInsert("qy_channelretent_config.INSERT_CONFIG", list);
	}

	@Override
	public List<ChannelRetentConfig> getConfigByMark(String mark) {
		List<ChannelRetentConfig> configDOlist = (List<ChannelRetentConfig>) redisClient.get(CacheKey.CHANNEL_RETENT_INFO_KEY + mark);
		if (configDOlist == null) {
			Map<String, String> params = new HashMap<String, String>();
			params.put("mark", mark);
			configDOlist = super.queryForList("qy_channelretent_config.GET_CONFIG_BY_MARK", params);
			if (configDOlist != null) {
				redisClient.put(CacheKey.CHANNEL_RETENT_INFO_KEY + mark, configDOlist, CacheKey.MEMCACHE_EXPIRY_TIME);
			}
		}
		return configDOlist;
	}

	@Override
	public List<ChannelRetentConfig> getRetentConfigListAll() {
		return super.queryForList("qy_channelretent_config.GET_RETENT_CONFIG_ALL");
	}

	@Override
	public List<ChannelRetentConfig> getConfigByMarkForPage(String mark) {
		Map<String, String> params = new HashMap<String, String>();
		params.put("mark", mark);
		return super.queryForList("qy_channelretent_config.GET_CONFIG_BY_MARK", params);
	}

	@Override
	public Integer deleteConfig(String mark) {
		Map<String, String> params = new HashMap<String, String>();
		params.put("mark", mark);
		return super.delete("qy_channelretent_config.DELETE_CONFIG", params);
	}

	@Override
	public Integer deleteChannelRetentConfig(ChannelRetentConfig form) {
		return super.delete("qy_channelretent_config.DELETE_CONFIG_DETAIL", form);
	}

	@Override
	public List<ChannelRetentConfig> getConfigByMarkForPageNew(List<String> keywords) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("keywords", keywords);
		return super.queryForList("qy_channelretent_config.GET_CONFIG_BY_MARK_NEW", params);
	}


	@Override
	public void update(ChannelRetentConfig config){
		super.update("qy_channelretent_config.UPDATE_CONFIG", config);
	}

}
